import type { Mapping, Option } from "@/components/ProFrom/ProFrom.vue";

import { useGlobalStore } from "@/stores";

const { dictionary, staffList } = useGlobalStore();

export const queryFormMap: Mapping[] = [
  { label: "值班人员", type: "input", prop: "name" },
  {
    label: "值班状态",
    type: "select",
    prop: "onDutyStatus",
    options: dictionary.onDutyStatus,
  },
  { label: "值班日期", type: "date", prop: "time" },
];

export const editFormMap: Mapping[] =
  //根据职位字典生成对应的多选下拉框配置项
  dictionary.position
    .map(({ prop, label }) => [
      {
        label,
        prop,
        type: "select",
        options: staffList,
        multiple: true,
      },
      {
        label: "职责",
        prop: prop + "Obligation",
        type: "textarea",
      },
    ])
    .flat()
    .concat([
      {
        label: "值班日期",
        type: "date",
        prop: "dutyDate",
        // isAfterToday: true,
      },
      // {
      //   label: "值班状态",
      //   type: "select",
      //   prop: "reponStatus",
      //   options: dictionary.reponStatus,
      // },
    ])
    .map((e) => ({ ...e, required: true })) as Mapping[];

export const detailMap: Mapping[] = [
  {
    label: "值班时间",
    type: "input",
    prop: "dutyDate",
  },
  {
    label: "值班电话",
    type: "input",
    prop: "phone",
  },
  {
    label: "值班人员",
    type: "table",
    prop: "watchStaffDtoList",
    columns: [
      {
        label: "姓名",
        prop: "name",
      },
      {
        label: "职位",
        prop: "position",
      },
      {
        label: "联系方式",
        prop: "phone",
      },
      {
        label: "岗位职责",
        prop: "job",
      },
    ],
  },
  {
    label: "值班状态",
    type: "radio",
    prop: "reponStatus",
  },
];
